package net.cyndeline.components.item

import net.cyndeline.ItemEffectType
import net.cyndeline.entitySystem.Component

/**
 * Information related to every item. Also acts as a tag to convey
 * that an entity is an actual item.
 */
trait ItemDescriptionComponent extends Component {
  
  /**
   * General types that describe what type of interactions this
   * item supplies its user.
   */
  def interactionTypes: Set[ItemEffectType]
  
  /** Adds a new interaction item type. */
  def addInteractionType(newType: ItemEffectType)
  
  /** Adds multiple interaction types. */
  def addInteractionType(newTypes: Set[ItemEffectType])
}

class ItemDescription extends ItemDescriptionComponent {
  private var types = Set[ItemEffectType]()
  
  override def interactionTypes = types
  
  override def addInteractionType(newType: ItemEffectType) {
    types += newType
  }
  
  override def addInteractionType(newTypes: Set[ItemEffectType]) {
    types = types | newTypes
  }
  
  override def copy = {
    val copy = new ItemDescription()
    copy.addInteractionType(types)
    copy
  }
}